package com.binarycat.dynamiclimit.bean;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.codahale.metrics.MetricRegistry;

/**
 * 动态限流信息存储类
 * 
 * @author jjb
 * @date 2018/08/06
 */
public class DynamicLimitData {

    /**
     * 度量注册中心
     */
    private final MetricRegistry metricRegistry = new MetricRegistry();

    /**
     * 限流策略对应的方法集合(即:对标识限流注解的方法进行归类)<br/>
     * key 限流策略类名,value:方法集合
     */
    private final Map<String, List<String>> limitPolicyMethodsMap = new ConcurrentHashMap<String, List<String>>();

    /**
     * 方法对应的限流信息映射<br/>
     * key 为完整的方法名或者ip拼接方法名如,"ip:127.0.0.1:"拼接上完整的法名
     */
    private final Map<String, MethodMappingLimitData> methodMappingLimitDataMap =
        new ConcurrentHashMap<String, MethodMappingLimitData>();

    /**
     * 扩展的限流数据
     */
    private AbstractExtendedLimitData extendedLimitData;

    public AbstractExtendedLimitData getExtendedLimitData() {
        return extendedLimitData;
    }

    public void setExtendedLimitData(AbstractExtendedLimitData extendedLimitData) {
        this.extendedLimitData = extendedLimitData;
    }

    public MetricRegistry getMetricRegistry() {
        return metricRegistry;
    }

    public Map<String, MethodMappingLimitData> getMethodMappingLimitDataMap() {
        return methodMappingLimitDataMap;
    }

    public Map<String, List<String>> getLimitPolicyMethodsMap() {
        return limitPolicyMethodsMap;
    }

}
